export default function myInfoWindow(options) {
    this.myDom = null;
    window.TMap.DOMOverlay.call(this, options);
    
}

// return false
myInfoWindow.prototype = new window.TMap.DOMOverlay();
myInfoWindow.prototype.onInit = function (options) {
    this.position = options.position;
    this.content = options.content;
    this.content2 = options.content2
    this.id = options.id
    this.stationId = options.stationId
};
myInfoWindow.prototype.createDOM = function () {
    console.log(this.stationId==this.id)
    if (this.stationId==this.id) {
        this.mydom = document.createElement("div");
        this.mydom.style.cssText = 'height:15px;padding:5px 10px;background:#fff;\
        line-height:18px;font-size:12px;position:absolute;top:-66px;left:0px;border-radius:5px;';
        this.mydom.innerHTML = "<p style='display:flex;align-items:center;'>" + this.content + "元/L<span style='margin:0 5px;display:block;width:1px;background:#555;height:12px'></span>" + this.content2 + "</p>";
        console.log(this.mydom)
        return this.mydom;
    }else{
        this.mydom = document.createElement("div");
        this.mydom.innerHTML = ""
        console.log(this.mydom)
        return this.mydom
    }
    
   
};
myInfoWindow.prototype.updateDOM = function () {
    if (!this.map) {
        return;
    }

    // 经纬度坐标转容器像素坐标
    let pixel = this.map.projectToContainer(this.position);

    //默认使用DOM左上角作为坐标焦点进行绘制（左上对齐）
    //如想以DOM中心点（横向&垂直居中）或其它位置为焦点，可结合this.dom.clientWidth和this.dom.clientHeight自行计算
    let left = pixel.getX() - this.dom.clientWidth / 2 + 'px'; //本例水平居中
    let top = pixel.getY() + 'px';

    //将平面坐标转为三维空间坐标
    this.dom.style.transform = `translate3d(${left}, ${top}, 0px)`;
};
myInfoWindow.prototype.updateContent = function (content) {
    this.mydom.innerHTML = content;
};
// myInfoWindow.prototype.destroy = function(){

// }